﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ActiproSoftware.Windows.Controls.PropertyGrid;
using ActiproSoftware.Windows.Controls.PropertyGrid.Primitives;
using ExpressionTreeLib;
using Expression = System.Linq.Expressions.Expression;

namespace EditorExe
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            //var visitor = new LoaderExpressionVisitor(new ServiceProvider(this.stackPanel1, this.treeView1));

            //var data1 = new int[] {0, 1};
            //var data2 = new int[] {2, 3};
            //var exp = (Expression<Func<string, string>>)(aaa => aaa.Substring(data1.Where(d => d == 0).FirstOrDefault(),
            //    data2.Where(d => d == 3).FirstOrDefault()));

            var exp = System.Linq.Dynamic.DynamicExpression.ParseLambda(new[]{ Expression.Parameter(typeof(string), "aaa")}, typeof(string), "aaa.Substring(0, 2)");
            var nvm = ExpressionNodeTypeMapping.Create(exp, null);
            nvm.ServiceProvider = new ServiceProvider(this.stackPanel1, this.treeView1);
            //visitor.Visit(exp);
            //var nvm = visitor.Model;
            this.treeView1.ItemsSource = new[] {nvm};
        }
    }
}
